home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / cygnused / uuencode.ced < prev   
Text File  |  1998-05-24  |  3KB  |  107 lines

  1. /* UUEncode.ced by Troels Walsted Hansen <troels@stud.cs.uit.no>
  2. ** $VER: UUEncode.ced 1.00 (24.9.95)
  3. **
  4. ** An ARexx script that uuencodes a file and imports it into the
  5. ** CygnusEd you are currently using. Unless the file is already
  6. ** archived this script will optionally do it for you (using LhA).
  7. **
  8. ** Utilises LhA by Stefan Boberg and either of the following:
  9. **    · UUFast v1.25 by Jørn Halonen
  10. **    · uuIn v1.03 by Nicolas Dade
  11. **    · UUxT v3.1 by Asher Feldman
  12. */
  13.  
  14. /* some user variables. edit to your hearts content */
  15.  
  16. tmpdir = "T:"        /* Work dir for the encoding        */
  17. uuencoder = "uuin"    /* may be: "uuin", "uufast" or "uuxt"    */
  18. uuprogpath = "C:"    /* Path to your uuencoder. This    path    */
  19.             /* MUST end with either ':' or '/'.    */
  20.  
  21. /* do NOT edit below here unless you know what you're doing :-) */
  22.  
  23. options results
  24.  
  25. /* needs GoldED and bbsread.library functions */
  26.  
  27. if(address() ~= 'rexx_ced') then
  28. do
  29.     say "This script should only be started from inside CygnusED."
  30.     exit 20
  31. end
  32. else gedport = address()
  33.  
  34. if ~show('p', 'BBSREAD') then
  35. do
  36.     address command
  37.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  38.         "WaitForPort BBSREAD"
  39. end
  40.  
  41. /* get filename */
  42.  
  43. address(bbsread)
  44. GETGLOBALDATA STEM GLOBALDATA
  45.  
  46. address('rexx_ced')
  47.  
  48. GETFILENAME '"'GLOBALDATA.UPLOADPATH'"'
  49. filetoencode = result
  50. if(rc ~= 0) then exit
  51.  
  52. lastchar = right(filetoencode,1)
  53. if(lastchar = "/" | lastchar = ":" | filetoencode = "RESULT") then
  54. do
  55.     OKAY1 'No file selected!'
  56.     signal exit
  57. end
  58.  
  59. posi = lastpos("/",FileToEncode)
  60. if(posi = 0) then posi = lastpos(":",FileToEncode)
  61. WithoutPath = substr(FileToEncode,posi+1)
  62.  
  63. /* if file isn't LhA'ed -- do it ourselves */
  64.  
  65. extension = upper(substr(FileToEncode, lastpos(".",FileToEncode)+1))
  66.  
  67. if~(extension = "LHA" | extension = "LZH") then
  68. do
  69.     OKAY2 'Do you want to LhA the file?'
  70.     if(result) then
  71.     do
  72.         address command "LhA >nil: -y -q a "||'"'tmpdir||WithoutPath'"'||" "||'"'FileToEncode'"'
  73.  
  74.         if(rc ~= 0) then OKAY1 'LhA''ing did not succeed.'
  75.         else FileToEncode = tmpdir||WithoutPath||".lha"
  76.     end
  77. end
  78.  
  79. select
  80.     when(upper(uuencoder) = 'UUFAST')    then cmd = uuprogpath || 'UUFast >nil: ' || '"' || filetoencode || '"' || " TO " || tmpdir || "Message.uu E"
  81.     when(upper(uuencoder) = 'UUIN')        then cmd = uuprogpath || 'uuIn >nil: INFILE=' || '"' || filetoencode || '"' || " OUTFILE=" || tmpdir || "Message.uu"
  82.     when(upper(uuencoder) = 'UUXT')        then cmd = uuprogpath || 'UUxT >nil: a ' || tmpdir || 'Message.uu ' || '"'filetoencode'"'
  83.     otherwise
  84.     do
  85.         OKAY1 'UUEncoder not configured correctly.'
  86.         signal exit
  87.     end
  88. end
  89. address command cmd
  90.  
  91. address('rexx_ced')
  92.  
  93. if ~exists(tmpdir"Message.uu") then
  94. do
  95.     OKAY1 'Something went wrong during uuencoding.'
  96.     signal exit
  97. end
  98.  
  99. INCLUDE FILE tmpdir || 'Message.uu'
  100.  
  101. /* cleanup and exit */
  102.  
  103. exit:
  104.     if(exists(tmpdir || WithoutPath || ".lha")) then address command 'delete >nil: ' || '"' || tmpdir || WithoutPath || '.lha' || '"'
  105.     if(exists(tmpdir || "Message.uu")) then address command 'delete >nil: ' || tmpdir || 'Message.uu'
  106.     exit
  107.